package controllers

import (
	"github.com/gin-gonic/gin"
	"go_anime_picture_api/models/response"
	"go_anime_picture_api/services"
	"net/http"
)

const passwd = "1103"

func AnimePicRandom(ctx *gin.Context) {

	returnType := ctx.DefaultQuery("type", "img")
	if returnType == "json" {
		ctx.JSON(http.StatusOK, response.SuccessR(services.RandomAnimePicInfo()))
	} else if returnType == "img" {
		ctx.Redirect(http.StatusFound, services.RandomAnimePicInfo().Url)
	} else {
		ctx.JSON(http.StatusOK, response.TypeErrorR)
	}
}

func MLTDCardRandom(ctx *gin.Context) {
	returnType := ctx.DefaultQuery("type", "img")
	if returnType == "json" {
		ctx.JSON(http.StatusOK, response.SuccessR(services.RandomMLTDCardInfo()))
	} else if returnType == "img" {
		ctx.Redirect(http.StatusFound, services.RandomMLTDCardInfo().Url)
	} else {
		ctx.JSON(http.StatusOK, response.TypeErrorR)
	}
}

func MLTDBigCardRandom(ctx *gin.Context) {
	returnType := ctx.DefaultQuery("type", "img")
	if returnType == "json" {
		ctx.JSON(http.StatusOK, response.SuccessR(services.RandomMLTDBigCardInfo()))
	} else if returnType == "img" {
		ctx.Redirect(http.StatusFound, services.RandomMLTDBigCardInfo().Url)
	} else {
		ctx.JSON(http.StatusOK, response.TypeErrorR)
	}
}

func MLTDBgRandom(ctx *gin.Context) {
	returnType := ctx.DefaultQuery("type", "img")
	if returnType == "json" {
		ctx.JSON(http.StatusOK, response.SuccessR(services.RandomMLTDBgInfo()))
	} else if returnType == "img" {
		ctx.Redirect(http.StatusFound, services.RandomMLTDBgInfo().Url)
	} else {
		ctx.JSON(http.StatusOK, response.TypeErrorR)
	}
}
